package edu.mis.modules.member;

import java.util.List;

import com.jfinal.plugin.activerecord.Record;

import edu.mis.model.Member;

public class MemberService {
	
	
	
	/**
	 * 关联查询_查询所有会员及其办卡人
	 * @return
	 */
	public List<Record> findAllMemberWithUserName(){
		return Member.dao.findAllRecord();
	}
	
	/**
	 * 添加日志
	 * @param member
	 * @return
	 */
	public boolean saveMember(Member member){  //service命名建议完整，见名知意。如此处的saveCustomer，参数尽量用对象
		if(member.findMemberByCustomerNumber(member.getCustomerNumber())==null) {
			return member.save();
		}
		else {
			return false;
		}
	}
	
	/**
	 * 根据ID得到会员
	 * @param memberId
	 * @return
	 */
	public Member findMemberByMemberId(int memberId) {
		return Member.dao.findById(memberId);
	}
	
	/**
	 * 根据会员编号得到会员
	 * @param customerNumber
	 * @return
	 */
	public Member findMemberByCustomerNumber(int customerNumber) {
		return Member.dao.findMemberByCustomerNumber(customerNumber);
	}
	
	/**
	 * 修改会员
	 * @param member
	 * @return
	 */
	public boolean updateMember(Member member){
		return member.update();
	}
	
	
	
	/**
	 * 删除日志
	 * @param memberId
	 * @return
	 */
	public boolean deleteMemberByMemberId(int memberId) {
		return Member.dao.deleteById(memberId);
	}
	
	
}
